<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>
<head>
<title><spring:message code="admin.cretemessage.title" /></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<script src="<c:url value="/javascripts/common.js"/>" type="text/javascript"></script>

<link rel="stylesheet" href="<c:url value="/javascripts/jscalendar/theme/calendar-system.css"/>" />
<script src="<c:url value="/javascripts/jscalendar/calendar-cfg.js"/>" type="text/javascript"></script>
<script src="<c:url value="/javascripts/calendar.js"/>" type="text/javascript"></script>
<script	src="<c:url value="/javascripts/jscalendar/lang/calendar-en.js"/>" type="text/javascript"></script>
<script src="<c:url value="/javascripts/jscalendar/calendar-setup.js"/>" type="text/javascript"></script>


<script language="javascript" type="text/javascript">
// script added by Umme Essa. The form should be validated on all operations.
	 function validateForm(){
		 
			 return (validate_required(document.getElementById("messageText"),'Please enter message text.')&& 
					 validate_required(document.getElementById("expiryDate"),'Please enter expiry date.'));
	 }
	 </script>
</head>
<body><%@include file="../top_menu.jsp"%>

<table width=100%>
	<tr>
		<td><c:import url="/WEB-INF/jsp/menu/admin_messages_menu.jsp" />
		<br />
		</td>
	</tr>
	<tr>
		<td><%@include file="/WEB-INF/jsp/include/messages.jsp"%>
		<br />
		</td>
	</tr>
</table>	<c:if test="${!empty errorList}">
<table><tr><td><spring:message code="admin.cretemessage.label.fixfollowingerrors" />

<c:forEach items="${errorList}" var="item" varStatus="i">
					${item.field} <spring:message code="admin.cretemessage.label.rejectedvalue" /> ${item.rejectedValue } 
				</c:forEach>
				
				</td></tr></table></c:if>
<form:form commandName="createMessage" method="post" onsubmit="return validateForm()">
	<table width=70% class="formTable">
		<tr class="formHeader">
			<td colspan="5"><spring:message code="admin.cretemessage.label.cretenewmessage" /></td>
		</tr>


		<tr>
			<td width="18%"><spring:message code="admin.cretemessage.label.role" /></td>
			<td width="80%"> <form:select path="roleId"><form:option value="-1">None</form:option>
				<c:forEach items="${roleList}" var="item" varStatus="i">
					<form:option value="${item.id}">${item.name}</form:option>
				</c:forEach>
			</form:select></td>
		</tr>

		<tr>
			<td width="18%"><spring:message code="admin.cretemessage.label.user" /></td>
			<td width="80%"><form:select path="userId"><form:option value="-1">None</form:option>
				<c:forEach items="${userList.pageItems}" var="user" varStatus="i">
					<form:option value="${user.id}">${user.email}</form:option>
				</c:forEach>
			</form:select></td>
		</tr>

	<tr>
			<td width="18%"><spring:message code="admin.cretemessage.label.messagetext" /></td>
			<td width="80%"><form:textarea path="messageText" rows="10" cols="40"/></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td width="18%"><spring:message code="admin.cretemessage.label.expires" /></td>
			<td width="80%"><component:calendar bindPath="expiryDate"/></td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td width="18%"><spring:message code="admin.cretemessage.label.active" /></td>
			<td width="80%"><form:checkbox path="active" /></td>
		</tr>
		
		<tr class="buttonPanel">
			<td><input type="submit" class='ui-button ui-state-default ui-corner-all' value="<spring:message code="admin.cretemessage.button.save" />" /></td>
		</tr>
	</table>
</form:form>
<%@include file="/WEB-INF/jsp/include/footer.jsp"%>
</body>
</html>